package com.kaluli.system.repository;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.kaluli.system.utils.Pageable;

public interface AbstractRepository<T> {

	T findById(java.io.Serializable pk);
	
	Serializable save(T entity);
	
	void update(T entity);

	void remove(T entity);
	
	List<T> findAll();
	
	List<T> query( Term term);	
	
	List<T> findHql(String hql , Object ...params);
	
	List<T> findHqlForMap(String hql , Map<String , Object> params);
	
	T findUniqueResult( Term term );
	
	/**
	 * 分页查询
	 * @param hql	   hibernate 查询语句
	 * @param number   当前页
	 * @param limit    每页限制多少行
	 * @param params
	 * @return
	 */
	Pageable<T> findHqlOfPageable(String hql , int number , int limit , Object ...params);
	Pageable<T> findHqlForMapOfPageable(String hql , int number , int limit , Map<String , Object> params);
}
